
import { locations } from "../../../gpu/locations";
const PointMaterial =/*wgsl*/`
override GAMM:f32=1.8;  

    struct Output {
      @location(0) color:vec4<f32>,
      #if ~{def.logarithmicDepth}
      @builtin(frag_depth) fragDepth:f32,
      #endif
      #if ~{def.gBuffer}
        @location(1) worldPos:vec4<f32>,
        @location(2) worldNormal:vec4<f32>,
        #if ~{def.enablePick}
         @location(3) pickColor:vec4<f32>,
        #endif
      #else
        #if ~{def.enablePick}
          @location(1) pickColor:vec4<f32>,
        #endif
      #endif
    };
    struct Input {
      @location(0) localPos:vec3<f32>,
      #if ~{def.map}
      @location(1) texcoord:vec2<f32>,
      #endif
      @location(2) color:vec4<f32>,
      #if ~{def.logarithmicDepth}
      @location(3) flogz : f32,
      #endif
    };
    #if ~{def.map}
    @group(${locations.map[0]}) @binding(${locations.map[1]}) var environmentMap: texture_2d<f32>;
    @group(${locations.mapSampler[0]}) @binding(${locations.mapSampler[1]}) var environmentMap_sampler:sampler;
    #endif
    #if ~{def.alphaCutoff}
     @group(${locations.alphaCutoff[0]}) @binding(${locations.alphaCutoff[1]})  var<uniform> alphaCutoff:f32;
    #endif
    @group(${locations.enableDarker[0]}) @binding(${locations.enableDarker[1]}) var<uniform> enableDarker:f32;
    @fragment
    fn main(input:Input) -> Output {
      var output:Output;
      if(enableDarker==1.0){
        output.color=vec4(0,0,0,1);
        #if ~{def.enablePick}
        output.pickColor=vec4(0,0,0,1);
        #endif
        #if ~{def.gBuffer}
          output.worldPos = vec4<f32>(input.localPos,-1.0);
          output.worldNormal = vec4<f32>(0,0,0,0);
        #endif
        #if ~{def.logarithmicDepth}
        output.fragDepth = log2(input.flogz ) * ~{def.logarithmicDepth} * 0.5;
        #endif
        return output;
      }
      output.color=input.color;
      #if ~{def.map}
        var tex= textureSample(environmentMap, environmentMap_sampler, input.texcoord);
        output.color*=tex;
      #endif
      // output.color=vec4f(input.color.rgb,output.color.a);
      #if ~{def.alphaCutoff}
      if(output.color.a<alphaCutoff){
        discard;
      }
      #endif 
      let kk=GAMM;
      #if ~{def.enablePick}
        output.pickColor=vec4(0,0,0,1);
      #endif
      #if ~{def.gBuffer}
        output.worldPos = vec4<f32>(input.localPos,-1.0);
        output.worldNormal = vec4<f32>(0,0,0,0);
      #endif
      #if ~{def.logarithmicDepth}
      output.fragDepth = log2(input.flogz ) * ~{def.logarithmicDepth} * 0.5;
      #endif
      return output;
    }`
export { PointMaterial }